package com.loctek.importexport.views;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class CustomViewPager extends ViewPager {

    private boolean horizontalScrollEnable = true;
    private boolean verticalScrollEnable = true;

    public CustomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (horizontalScrollEnable) {
            return super.onTouchEvent(event);
        }
        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (horizontalScrollEnable) {
            //for this project special fix
            if (event.getPointerCount() == 1 && (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE)) {
                try {
                    super.onTouchEvent(event);
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                }

            }
            return super.onInterceptTouchEvent(event);
        }
        return false;
    }

//	public boolean isHorizontalScrollEnable() {
//		return horizontalScrollEnable;
//	}

    public void setHorizontalScrollEnable(boolean horizontalScrollEnable) {
        this.horizontalScrollEnable = horizontalScrollEnable;
    }

//	public boolean isVerticalScrollEnable() {
//		return verticalScrollEnable;
//	}

//	public void setVerticalScrollEnable(boolean verticalScrollEnable) {
//		this.verticalScrollEnable = verticalScrollEnable;
//	}


}